
const until={
	setCookie(name,value){
		var Days = 29; 
		var exp = new Date(); 
		exp.setTime(exp.getTime() + Days*24*60*60*1000); 
		document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
	},
	getCookie(name){
		var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
		if(arr=document.cookie.match(reg))
			return unescape(arr[2]); 
		else 
			return null; 
	},
	delCookie(name){
		var exp = new Date(); 
		exp.setTime(exp.getTime() - 1); 
		var cval=this.getCookie(name); 
		if(cval!=null) 
			document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 
	},
	getParameter(variable) {
		var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
      }
      return(false);
	},
	getNowDayTime(){
		let date=new Date().getTime();
		return date;
	},
	getAddDayTime(num){
		let date= new Date().getTime()+num*24*60*60*1000;
		return date;
	},
	guid() {
		function S4() {
			return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
		}
		return (S4()+S4());
	},



	getAddDayFirst(num){
		let date= new Date().getTime()+num*24*60*60*1000;
		let ymdDate=new Date(date);
		let ym_year=ymdDate.getFullYear();
		let ym_month=ymdDate.getMonth()+1;
		let ym_day=ymdDate.getDate();
		let firstDate=Date.parse(ym_year+'-'+ym_month+'-'+ym_day+" 00:01")
		return firstDate;
	},

	getAddDayLast(num){
		let date= new Date().getTime()+num*24*60*60*1000;
		let ymdDate=new Date(date);
		let ym_year=ymdDate.getFullYear();
		let ym_month=ymdDate.getMonth()+1;
		let ym_day=ymdDate.getDate();

		console.log(ymdDate)
		let firstDate=Date.parse(ym_year+'-'+ym_month+'-'+ym_day+" 23:59")
		return firstDate;
	},

	getDayFirst(date){
		let dateTime=this.formatDate(date)+" 00:01";
		console.log(dateTime)
		return new Date(dateTime)

	},
	getDayLast(date){
		let dateTime=this.formatDate(date)+" 23:59";
		console.log(dateTime)
		return new Date(dateTime)
	},
	getNowDay(){
		let date=new Date().getTime();
		return this.formatDate(date)
		
	},
	getAddDay(num){
		let date= new Date().getTime()+num*24*60*60*1000;
		return this.formatDate(date)
	},
	getNowWeekBegin(){
		var now = new Date();
		var nowDayOfWeek=now.getDay();
		if(nowDayOfWeek==0){
			nowDayOfWeek=7;
		}
		nowDayOfWeek--;
		console.log(nowDayOfWeek)
		var weekStartDate = this.getAddDay(-nowDayOfWeek);
		return weekStartDate
		
	},
	removeHtmlTags(html) {
		html = html.replace(/&nbsp;/g, ' ')
		var regExp = /<[^>]+>/g; // 定义正则表达式，匹配任意HTML标签
		return html.replace(regExp, ''); // 将匹配到的HTML标签替换成空字符串
	},
	
	getNewAddDay(oldDate,num){
		let date= new Date(oldDate).getTime()+num*24*60*60*1000;
		return this.formatDate(date)
	},
	getYMDNow(){
		let year=new Date().getFullYear();
			let month=new Date().getMonth()+1;
			let day=new Date().getDate();
			let hour=new Date().getHours();
			let min=new Date().getMinutes();
			if(month<10){
				month="0"+month
			}
			if(day<10){
				day="0"+day
			}
			if(hour<10){
				hour="0"+hour
			}
			if(min<10){
				min="0"+min
			}
			return year+'-'+month+'-'+day+" "+hour+":"+min
	},
	//格式化日期：yyyy-MM-dd
	formatDate(date) {
		date=new Date(date)
		var myyear = date.getFullYear();
		var mymonth = date.getMonth()+1;
		var myweekday = date.getDate();
		
		if(mymonth < 10){
			mymonth = "0" + mymonth;
		}
		if(myweekday < 10){
			myweekday = "0" + myweekday;
		}
		return (myyear+"-"+mymonth + "-" + myweekday);
	},
	formatDateDay(date) {
		date=new Date(date)
		var myyear = date.getFullYear();
		var mymonth = date.getMonth()+1;
		if(mymonth < 10){
			mymonth = "0" + mymonth;
		}
		return (myyear+"-"+mymonth);
	},
	formatDateHour(date) {
		date=new Date(date)
		var myyear = date.getFullYear();
		var mymonth = date.getMonth()+1;
		var myweekday = date.getDate();
		var myhour=date.getHours();
		let mymin=date.getMinutes();
		if(mymonth < 10){
			mymonth = "0" + mymonth;
		}
		if(myweekday < 10){
			myweekday = "0" + myweekday;
		}
		if(myhour<10){
			myhour="0"+myhour
		}
		if(mymin<10){
			mymin="0"+mymin
		}
		return (myyear+"-"+mymonth + "-" + myweekday+" "+myhour+":"+mymin);
	},
	dateHour(date) {
		date=new Date(date)
		var myyear = date.getFullYear();
		var mymonth = date.getMonth()+1;
		var myweekday = date.getDate();
		var myhour=date.getHours();
		let mymin=date.getMinutes();
		if(mymonth < 10){
			mymonth = "0" + mymonth;
		}
		if(myweekday < 10){
			myweekday = "0" + myweekday;
		}
		if(myhour<10){
			myhour="0"+myhour
		}
		if(mymin<10){
			mymin="0"+mymin
		}
		return (myhour+":"+mymin);
	},
	//计算两个时间之间的时间差 多少天时分秒
	intervalTime(startTime, endTime) {
		let timestamp = (Date.parse(new Date())) / 1000;//计算当前时间戳 (毫秒级)
		let date1 = ""; //开始时间
		if (timestamp > startTime) {
			date1 = startTime;
		} else {
			date1 = timestamp; //开始时间
		}
		let date2 = endTime; //结束时间
		let date3 = (date2 - date1) * 1000; //时间差的毫秒数

		//计算出相差天数
		let days = Math.floor(date3 / (24 * 3600 * 1000));
		//计算出小时数

		let leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
		let hours = Math.floor(leave1 / (3600 * 1000));
		//计算相差分钟数
		let leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
		let minutes = Math.floor(leave2 / (60 * 1000));

		//计算相差秒数

		let leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
		let seconds = Math.round(leave3 / 1000);
		return   hours + "小时" + minutes + "分" + seconds+'秒'
	},
	getWid(){
		let url=window.location.href.split("#")[0];
		let urlarry=url.split("/");
		let wid="";
		urlarry.map((res,index)=>{
			if(res=='wid'){
				wid=urlarry[index+1]
			}
		})
		return wid
	},
	
  

}
export default until;